Skip to content

[ fix ] : #427 블로그의 게시글 리스트 최신순, 추천순에 첨부이미지 썸네일로 연결되게 백엔드 수정#428

Merged
treejh merged 3 commits intomainfrom
fix/#389-임시로
Apr 30, 2025

Hidden character warning

The head ref may contain hidden characters: "fix/#389-\uc784\uc2dc\ub85c"
Merged

[ fix ] : #427 블로그의 게시글 리스트 최신순, 추천순에 첨부이미지 썸네일로 연결되게 백엔드 수정#428
treejh merged 3 commits intomainfrom
fix/#389-임시로

Conversation

@backsunyoung
Copy link
Collaborator

블로그 리스트에 첨부이미지 썸네일로 연결되게 백엔드 수정

@vercel
Copy link

vercel bot commented Apr 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
book-tree ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 30, 2025 5:26pm


// Redis 의존성
implementation ("org.springframework.boot:spring-boot-starter-data-redis")
// implementation ("org.springframework.boot:spring-boot-starter-data-redis")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis 의존성을 주석 처리했습니다. Redis를 사용하지 않는다면 문제없지만, 추후 Redis를 사용할 계획이 있다면 주석을 해제해야 합니다. 사용 여부를 명확히 결정하고 주석을 남겨주세요. 사용하지 않는다면, 왜 사용하지 않는지에 대한 이유를 추가로 코멘트로 남겨주는 것이 좋습니다.

private String imageUrl;
private double score;

private String content; // 추가

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostResponseDto에 content, username, categoryId, category 필드를 추가했습니다. username과 category는 user.getNickname() 또는 user.getName(), category.getName()과 같이 적절한 getter 메소드를 사용하여 값을 설정해야 합니다. null값 처리에 대한 고려가 필요하며, 필드에 대한 자세한 설명(Javadoc)을 추가하는 것이 좋습니다.

.viewCount(post.getView())
.createdAt(post.getCreatedAt())
.modifiedAt(post.getModifiedAt())
.imageUrl(post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl()) // 추가!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imageUrl 설정 부분에 post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl() 를 추가했습니다. 이미지 목록이 비어있는 경우 null을 반환하는 것은 좋은 방법입니다. 하지만, getImageList().get(0) 부분은 isEmpty() 체크를 이미 했으므로 IndexOutOfBoundsException 발생 가능성은 낮지만, 더 안전하게 post.getImageList().stream().findFirst().map(image -> image.getImageUrl()).orElse(null) 과 같이 Optional을 활용하는 것이 좋습니다. 코드 가독성을 높이는 방향으로 개선하는 것을 추천합니다.

.viewCount(post.getView())
.createdAt(post.getCreatedAt())
.modifiedAt(post.getModifiedAt())
.imageUrl(post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl()) // 추가

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

504번 라인과 동일한 문제입니다. Optional을 활용하여 IndexOutOfBoundsException 예외 발생 가능성을 제거하고 코드 가독성을 높이는 것이 좋습니다. post.getImageList().stream().findFirst().map(image -> image.getImageUrl()).orElse(null) 와 같이 변경하는 것을 권장합니다.

@treejh treejh merged commit 7d11d66 into main Apr 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants